/**
 * Created by Administrator on 2016/8/4.
 */
// 加载数据

    $(function () {
        $('#table').bootstrapTable({
            method: "get",
            striped: true,
            singleSelect: false,
            url: "resume.json", 
            dataType: "json",
            pagination: true, //分页
            pageSize: 10,
            pageNumber: 1,
            search: false, //显示搜索框
            contentType: "application/x-www-form-urlencoded",
            queryParams: null,
            columns: [
                {
                    checkbox:"true",
                    field: 'ID',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: "姓名",
                    field: 'name',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '性别',
                    field: 'rt_sex',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '毕业院校',
                    field: 'graduate',
                    align: 'center'
                },
                {
                    title: '学历',
                    field: 'rt_education',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '专业',
                    field: 'major',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '应聘职位',
                    field: 'rt_post',
                    align: 'center'
                },
                {
                    title: '工作经验',
                    field: 'workExperience',
                    align: 'center'
                },
                {
                    title: '登记日期',
                    field: 'registraTime',
                    align: 'center'
                },
                {
                    title: '简历状态',
                    field: 'resumeState',
                    align: 'center',
                    
                    formatter: function(value, row, index){
                    	var startsId = value;
            			var BigId = row.id;
            			
                    	$.ajax({
                    		url:'rst.json',
                    		type:"get",
                    		data : {},
                    		dataType: "json",
                    		async:false,
                    		success:function(e){
                    			
                    			var headOption = "<option value =''>请选择</option>";
                    			  $.each(e,function(i,obj){
                    				  if(value==obj.id){
                    					  
                    					  headOption = headOption +"<option value='"+obj.id+"'selected>"+obj.resume+"</option>"
                    				  }else{
                    					  headOption = headOption +"<option value='"+obj.id+"'>"+obj.resume+"</option>"
                    				  } 
                    				  
                    			}); 
                    			  /*  option = "<select id=ResumeStates onchange = change('"+value+"')>"+headOption +"</select>"*/
                    			  option="<select id=resumeState onchange = change('"+startsId+"','"+BigId+"',this.options[this.options.selectedIndex].value)>"+headOption +"</select>"
                    		
                    		}
                    	})
                    	return option;
                    }
                },
                {
                    title: '操作',
                    field: 'id',
                    align: 'center',
                    formatter: function (value, row) {
                        var e = '<a  href="rt_resumeUpd.html/'+row.id+'">修改</a> ';
                        
                        var resum =row.resumeState
                        var b='';
                        if(resum>=3){
                        	b = '<a  href="resumefiesig_select.html/'+row.id+'" >明细</a> '; 
                        }else{
                        	b = '<a  href="rt_resumeselect.html/'+row.id+'" >明细</a> ';
                        }
                        
                        	
                        /*var d = '<a  href="#" onclick="delet(\'' + row.id + '\')">删除</a> ';*/
                        var d = '<a  href="#" onclick="de(\'' + row.id + '\')">删除</a> ';
                        var re=row.rt_post
                        var f='';
                        if(re==null || re==''){
                        	f = '<a  href="#" onclick="openlayer_resume(\'' + row.id + '\')">应聘职位</a> ';
                        
                        
                        }
                       
                        return e+b+d+f;
                    }
                }
            ]
        });
       // getData();
    });
    
    function getData() {
    	var names,postId,workExperience,resumeState,registraTime;
    	name =  $("#name").val();
    	postId =  $("#postId").val();
    	workExperience = $("#workExperience").val();
    	resumeState = $("#resumeState").val();
    	registraTime = $("#registraTime").val();
   	    $.ajax({
   	        type: "GET",
   	        url: "reumesss.json",
   	        dataType: "json",
   	        data:{
   	        	"name":name,
   	        	"rt_post":postId,
   	        	"workExperience":workExperience,
   	        	"resumeState":resumeState,
   	        	"registraTime":registraTime
   	        },
           success: function (result) {
               if (result.data) {
                   var TableData = result.data;
                   $('#table').bootstrapTable("load", TableData);
               }
           }
       })
   }
 // 删除操作
    function de(id){
    	
    	var sc = confirm("确定要永久删除该条数据吗？");
    	if (sc) {
    		$.ajax({
    			url : 'delete.json',
    			type : 'GET',
    			data:{"id":id},
    			dataType : 'json',
    			success : function(data) {
    				if (data.data) {
    					var TableData = data.data;
    					$("#table").bootstrapTable('refresh', data.data);//刷新表格
    					alert("删除成功！")
    				} else {
    					alert("删除失败！")
    				}
    			},
    			error : function(err) {
    			}
    		});
    	}
    }
    
    
    	
    
    function change(startsId,BigId,index){
    	var id = BigId;//简历表ID   	
    	var StartsId = startsId;//简历状态ID
    	if(index==2){
    		$.ajax({
    			url : 'RecritmentNews.json',
    			type : 'GET',
    			data:{
    				"id":id,
    				"resumeState":StartsId
    				},
    			dataType : 'json',
    			async :false,
    			success : function(e) {
    				 $.each(e,function(i,obj){
    					document.getElementById("recritmentName").value = obj.recritmentName;
    		        	document.getElementById("recritmentdate").value = obj.recritmentdate;
    		        	document.getElementById("id").value =id;
    		        	$('#myModals').modal('show');
    				 });
    			}
    			
    		});

    	}else
        	if(index>2){
        		$('#myModal').modal('show')
        	}
    	
    		
        		
    
    
   
//时间控件
    !function(){
        laydate.skin('molv');//切换皮肤，请查看skins下面皮肤库
        laydate({elem: '#registraTime'});//绑定元素
    }();


   

 
 /*   function delet(id) {
    	alert("删除")
    	var sc = confirm("确定要永久删除该条数据吗？");
    	if (sc) {
    		$.ajax({
    			url : 'delete.json',
    			type : 'GET',
    			data:{"id":id},
    			dataType : 'json',
    			success : function(data) {
    				if (data.data) {
    					var TableData = data.data;
    					$("#table").bootstrapTable('refresh', data.data);//刷新表格
    					alert("删除成功！")
    				} else {
    					alert("删除失败！")
    				}
    			},
    			error : function(err) {
    			}
    		});
    	}

    }*/

    }

// 下载操作
function down(id) {
    alert(id)
    var NId = id;
    $.ajax({
        url: '../WorkRecord/DeleteWork?workId=' + NId,
        type: 'GET',
        dataType: 'json',
        success: function (data) {
            if (data.data) {
                alert("下载成功！")

            } else {
                alert("下载失败")
            }
        },
        error: function (err) {
        }
    });
}
function getCurrentID(id) {
    return currentID;
}





